<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
    <script>
        function f1(){
            let user = {"id":1,"username":"admin","password":"123456"};
            console.log(user)
            console.log(user.id)
            console.log(user['username'])
            console.log(user["password"])
        }
        function f2(){
            let address = {"province":"江苏","city":"南京"};
            let user = {"id":1,"username":"admin","password":"123456","address":address};
            let user2 = {"id":1,"username":"admin","password":"123456","address":{"province":"江苏","city":"南京"}};
            console.log(user.address.province);
            console.log(user2.address["city"]);
        }
        function f3(){
            let users = [{
                "id":1,
                "username":"admin",
                "password":"111111"
            },{
                "id":2,
                "username":"jack",
                "password":"222222"
            },{
                "id":1,
                "username":"tom",
                "password":"333333"
            }];
            console.log(users)
            console.log(users[0].id)
            console.log(users[1].username)
            console.log(users[2].password)
        }
    </script>
</head>
<body>
<button onclick="f1()">基本语法</button><br>
<button onclick="f2()">对象中包含对象</button><br>
<button onclick="f3()">对象数组</button><br>
</body>
</html>